<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            text-align: center;
            line-height: 30px;
            height: 30px;
            float: left;
            font-size: 14px;
            color: #ccc;
        }

        p {
            display: inline;
            background: url(images/叉\ .png) no-repeat;
            padding-left: 20px;
            vertical-align: middle;
        }

        .wrong {
            color: red;
        }
        .right {
            background-image: url(images/对.png);
            color: green;
        }
    </style>
</head>

<body>
    <div class="box">
        <input type="password" class="ipt">
        <p class="message">
          
            请输入6~16之间位数
        </p>
    </div>
    <script>
        var ipt = document.querySelector('.ipt');
        var message = document.querySelector('.message');
        //注册事件   处理程序
        ipt.onblur = function () {
            if (this.value.length < 6 || this.value.length > 16) {
                message.className = 'wrong';
                message.innerHTML = '你输入的错误：';
            } else {
                message.className = 'right';
                message.innerHTML = '您输入的正确'
            }
        }
    </script>
</body>

</html>